/**
 * 
 */
package wator.view.swing.jogl;

import javax.media.opengl.GL2;

import wator.model.Agent;
import wator.model.Integer3DVector;
import wator.model.IntegerVector;
import wator.view.swing.enums.AvailableColors;

public class SphereDrawingStrategy extends JoglDrawingStrategy {

	private final float SPHERE_SIZE = 0.3f;
	
	public SphereDrawingStrategy(AvailableColors color) {
		super(color);
	}
	
	/* (non-Javadoc)
	 * @see wator.view.swing.jogl.JoglDrawingStrategy#draw(wator.model.Agent)
	 */
	@Override
	public void draw(Agent agent) {
		GL2 gl = drawable.getGL().getGL2();
		gl.glMatrixMode(GL2.GL_MODELVIEW);
		gl.glLoadIdentity();
		
		Integer3DVector pos = vectorFactory.generateVector(
				agent.getPositionVector());
		gl.glTranslatef(pos.getX(), pos.getY(), pos.getZ());
		
		
		gl.glDisable(GL2.GL_BLEND);
		gl.glEnable(GL2.GL_DEPTH_TEST);
	    gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE); 
		float[] c = getColor4f();
		gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, c, 0);
		glut.glutSolidSphere(SPHERE_SIZE, 10, 10);
		
		if (showNeighborhoodRadius) {
			float[] cT = {c[0], c[1], c[2], ALPHA};
			gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, cT, 0);
			gl.glEnable(GL2.GL_BLEND);
		    gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE); 
			gl.glDisable(GL2.GL_DEPTH_TEST);
			glut.glutSolidSphere(neighborhoodRadius, 15, 15);

			gl.glDisable(GL2.GL_BLEND);
			gl.glEnable(GL2.GL_DEPTH_TEST);
		}
		
	}

}
